<?php
include_once 'include/config.php';
$spec = 'templates/avod.json';
$sqlite = "paxgui_content.sqlite";
?>
<!DOCTYPE html>
<html>
<head>
	<title></title>
<style type="text/css">
html, body {
	font-family:tahoma;
	font-size:10pt;
}

ul {
	list-style-type:square;
	list-style-position:outside;
	padding-left:20px;
}

ul li {
	padding:0px;
	margin:0px;
}

.noDisplay {
	padding:2px;
}

#contentList {
	display:table;
	position:absolute;
	padding:3px;
	left:200px;
	top:0px;
	width:700px;
	clear:both;
	font-size:9pt;
}

.contentItem {
	display:inline;
	width:100px;
	height:100px;
	padding:2px;
	margin:2px;
	border:1px solid black;
	float:left;
}
</style>

<script language="javaScript" src="js/jquery-1.10.2.min.js"></script>
<script language="javaScript">
var CURRENT_ID = '';

function showContent(id) {
	if (CURRENT_ID != '') {
		$("#" + CURRENT_ID).toggle();
	}

	$("#" + id).toggle();
	CURRENT_ID = id;
}

function hideContentList() {
	$(".noDisplay").toggle();
}
</script>

</head>
<body onload="hideContentList();">
<?php
$obj = new Process($sqlite, $spec, 25);
$tasks = json_decode(file_get_contents('templates/main.json'), true);

foreach ($tasks as $type => $task) {
	$obj->start($task, $type);
}

$genreList = $obj->getGenreList();

/**
 * building genre tree
 * */

foreach ($genreList as $type => $list) {
	echo '<h1>' . $type . '</h1>';
	$obj->buildGenreTree($list, $type);
}

unset($genreList); // release memory
/**
 * building content base on genre leaf
 * */

$genreLeaf = $obj->getGenreLeaf();

echo '<div id="contentList">';
foreach ($genreLeaf as $type => $genreList) {
	foreach ($genreList as $genreId) {
		$obj->buildContentList($tasks[$type], $type, $genreId);
	}
}
echo '</div>';

?>

</body>
</html>
